/* @(#)GSManufactureCategoryScanQueryAction.java    V0.1
 *
 * Project: GSdevelop
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   owen         2006-2-28
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import java.util.HashMap;

import com.hitrust.gs.bean.GSManufactureCategoryBean;
import com.hitrust.gs.business.GSManufactureCategoryProcessor;
import com.hitrust.gs.business.GSManufactureProcessor;
import com.hitrust.gs.form.GSManufactureCategoryScanForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.util.page.ResultProcess;

/**
 *  查询产品种类列表
 */
public class GSManufactureCategoryScanQueryAction extends GSBaseAction{

    public String execute(GSBaseForm aForm) throws Exception {
        GSManufactureCategoryScanForm tForm = (GSManufactureCategoryScanForm)aForm;
        GSManufactureProcessor tGSManufProcessor = new GSManufactureProcessor();
        //String tCategoryId=tForm.getCategory_id()==null?"":tForm.getCategory_id().trim();
        String tCategoryName=tForm.getCategory_name()==null?"":tForm.getCategory_name().trim();
  //      String tCategoryId="";
        String tCategoryId1=tForm.getManuftype1();
        String tCategoryId2=tForm.getManuftype2();
//        if(tCategoryId1.equals("0")){
//            tCategoryId=tCategoryId1;
//        }
//        else if(tCategoryId2.equals("0")){
//            tCategoryId=tCategoryId1;
//        }
//        else{
//            tCategoryId=tCategoryId2;
//        }
        try{
        //通过机构编号和机构名称
        ArrayList tCategory=GSManufactureCategoryProcessor.queryManageCategory(tCategoryId1,tCategoryId2,tCategoryName);
        
        ResultProcess tRsProc = new ResultProcess();
        ArrayList tList = new ArrayList();
        
        GSManufactureCategoryBean tGSManufactureCategoryBean=new GSManufactureCategoryBean();
        if (tCategory != null && tCategory.size() > 0) {
            for (int i = 0; i < tCategory.size(); i++) {
                tGSManufactureCategoryBean = (GSManufactureCategoryBean) tCategory.get(i);
                String[] tStr = new String[7];
                tStr[0]=tGSManufactureCategoryBean.getGs_manufacture_category_id();
                tStr[1]=tGSManufactureCategoryBean.getGs_manufacture_category_name();
                tStr[2]=tGSManufactureCategoryBean.getGs_manufacture_level();
                tStr[3]=tGSManufactureCategoryBean.getGs_manufacture_category_id1();
                tStr[4]=tGSManufactureCategoryBean.getGs_manufacture_category_id2();
                tStr[5]=tGSManufactureCategoryBean.getGs_manufacture_desc();
                tStr[6]=tGSManufactureCategoryBean.getGs_is_tradeflat_manuf_category();
                tList.add(tStr);
            }
            tRsProc.setResult(tList);
            }
        tForm.getRequest().setAttribute("CategoryList", tRsProc);
        
        //种类等级
        tGSManufProcessor.getManufactureOfLevel(aForm);
        aForm.getRequest().setAttribute("requery","false");
        //暂时用此方法传递分页参数
        //tForm.getRequest().setAttribute("choice",tForm.getRequest().getParameter("choice"));

        }catch(GSException e){
            tForm.getRequest().setAttribute("action","A200101.do");
            throw e;
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            tForm.getRequest().setAttribute("action","A200101.do");
            throw new GSException(GSException.E10030,GSException.E10030_MSG);
        }
        return GSBaseConstants.FORWARD_SUCCESS;
    }

}
